"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const getCwd_1 = __importDefault(require("./getCwd"));
exports.default = (dir) => {
    let currentPkg;
    // 加载当前模块
    try {
        currentPkg = require(path_1.join(getCwd_1.default(), 'package.json'));
    }
    catch (error) {
        try {
            currentPkg = require(path_1.join(dir, 'package.json'));
        }
        catch (error) {
            currentPkg = {};
        }
    }
    // 父模块
    let parent;
    try {
        parent = require(path_1.resolve(getCwd_1.default(), '../../package.json'));
    }
    catch (e) {
        try {
            parent = require(path_1.resolve(dir, '../../package.json'));
        }
        catch (error) {
            parent = {};
        }
    }
    currentPkg = Object.assign(Object.assign({}, currentPkg), { devDependencies: Object.assign(Object.assign({}, (currentPkg.devDependencies || {})), (parent.devDependencies || {})), dependencies: Object.assign(Object.assign({}, (currentPkg.dependencies || {})), (parent.dependencies || {})) });
    return currentPkg;
};
